//
//  CXHWebImageError.h
//  CXHAdSDK-Kit
//
//  Created by 陈坤 on 2023/9/10.
//

#import "CXHWebImageCompat.h"

/// An error domain represent CXHWebImage loading system with custom codes
FOUNDATION_EXPORT NSErrorDomain const _Nonnull CXHWebImageErrorDomain;

/// The response instance for invalid download response (NSURLResponse *)
FOUNDATION_EXPORT NSErrorUserInfoKey const _Nonnull CXHWebImageErrorDownloadResponseKey;
/// The HTTP status code for invalid download response (NSNumber *)
FOUNDATION_EXPORT NSErrorUserInfoKey const _Nonnull CXHWebImageErrorDownloadStatusCodeKey;
/// The HTTP MIME content type for invalid download response (NSString *)
FOUNDATION_EXPORT NSErrorUserInfoKey const _Nonnull CXHWebImageErrorDownloadContentTypeKey;

/// CXHWebImage error domain and codes
typedef NS_ERROR_ENUM(CXHWebImageErrorDomain, CXHWebImageError) {
    CXHWebImageErrorInvalidURL = 1000, // The URL is invalid, such as nil URL or corrupted URL
    CXHWebImageErrorBadImageData = 1001, // The image data can not be decoded to image, or the image data is empty
    CXHWebImageErrorCacheNotModified = 1002, // The remote location specify that the cached image is not modified, such as the HTTP response 304 code. It's useful for `CXHWebImageRefreshCached`
    CXHWebImageErrorBlackListed = 1003, // The URL is blacklisted because of unrecoverable failure marked by downloader (such as 404), you can use `.retryFailed` option to avoid this
    CXHWebImageErrorInvalidDownloadOperation = 2000, // The image download operation is invalid, such as nil operation or unexpected error occur when operation initialized
    CXHWebImageErrorInvalidDownloadStatusCode = 2001, // The image download response a invalid status code. You can check the status code in error's userInfo under `CXHWebImageErrorDownloadStatusCodeKey`
    CXHWebImageErrorCancelled = 2002, // The image loading operation is cancelled before finished, during either async disk cache query, or waiting before actual network request. For actual network request error, check `NSURLErrorDomain` error domain and code.
    CXHWebImageErrorInvalidDownloadResponse = 2003, // When using response modifier, the modified download response is nil and marked as failed.
    CXHWebImageErrorInvalidDownloadContentType = 2004, // The image download response a invalid content type. You can check the MIME content type in error's userInfo under `CXHWebImageErrorDownloadContentTypeKey`
};
